home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr11
/
pdox693.zip
/
TI375.ASC
< prev
next >
Wrap
Text File
|
1993-03-18
|
5KB
|
199 lines
PRODUCT : Paradox NUMBER : 375
VERSION : All
OS : DOS
DATE : March 18, 1993 PAGE : 1/3
TITLE : Formatting Phone Number Fields
Sometimes it is necessary to manipulate alphanumeric data and
change its format. One common example is data imported from a
mainframe. Another example is data that has leading spaces.
This document demonstrates a PAL script that modifies the format
of data in a phone number field, containing 10 digits (for
example 4084399096), in one of the following three formats:
1) ###-###-####, 2) (###) ###-####, 3) (###)###-####.
The script will divide the phone number field into three sections
1) characters 1 through 3 for the area code, 2) characters 4
through 6 for the prefix, and 3) characters 7 through 10 for the
suffix. It will reformat the phone number field according to
one of the formats described above by combining the three
sections with the appropriate string values (i.e. "(", ")", and
"-"). The script illustrates the PAL commands EDIT and SCAN, and
the PAL function SUBSTR().
NOTE: Before making global changes to your table, it is a good
idea to first make a backup copy.
Depending on the phone number format that you choose (1, 2 or 3
shown above), the phone number field will need to have a length
of 12, 13 or 14. This will require restructuring your table.
For example, if you want to reformat the phone number field as
###-###-####, and the data type of the Phone field is less than
of 12 characters, you will need to first Modify | Restructure
your table to increase the field length of the Phone field to 12
characters to accommodate the two hyphens before running the
script. Please note that performing a Modify | Restructure and
changing the field length of your Phone field will remove the
Phone field from your existing Forms and Reports. You will need
to modify your existing Forms and Reports to replace the Phone
field.
Creating the script:
o From the Main menu, select Scripts | Editor | New (if you
are using version 3.5 or earlier, this will be Scripts |
Editor | Write).
o Type the name of the script (i.e. Phone) and press Enter.
PRODUCT : Paradox NUMBER : 375
VERSION : All
OS : DOS
DATE : March 18, 1993 PAGE : 2/3
TITLE : Formatting Phone Number Fields
You are now in the Script Editor. Type the script that
appears below. You will need to substitute your own table
name for "Tbl" and your own field name for "Phone".
; Here is the script
COEDIT "Tbl" ;where Tbl is
; the table name
SCAN ;scans every record
a=SUBSTR([Phone], 1, 3) ;variable assignment
b=SUBSTR([Phone], 4, 3)
c=SUBSTR([Phone], 7, 4)
IF LEN([Phone])=10 THEN
;UNREMARK ONE OF THE OPTIONS BELOW BY REMOVING THE ";"
;[Phone]=a+"-"+b+"-"+c ; ###-###-#### format
;[Phone]="("+a+") "+b+"-"+c ; (###) ###-#### format
;[Phone]="("+a+")+b+"-"+c ; (###)###-#### format
ENDIF
ENDSCAN
; End of the script
NOTE: The semicolon ";" indicates that a comment
follows and the information on that line will not be
executed when you play the script. Depending on the
format that you choose, you will need to remove the ";"
that precedes that option. For example, to format the
phone number field as ###-###-####, you will need to
remove the ";" that precedes the code:
[Phone]=a+"-"+b+"-"+c ; ###-###-#### format
o When you have finished typing the script, press F2 to save
the script.
Playing the script:
o From the Main menu, select Scripts | Play, type the name
of your script (i.e. Phone), then press Enter.
PRODUCT : Paradox NUMBER : 375
VERSION : All
OS : DOS
DATE : March 18, 1993 PAGE : 3/3
TITLE : Formatting Phone Number Fields
Paradox will modify every record in your table and
separate the area code, the prefix, and suffix with
hyphens. When the script is finished you will still be in
Coedit mode. To save the table, press F2.
For additional reference on these and other PAL commands and
functions, refer to the PAL Reference Guide (for versions earlier
than 4.0, refer to the PAL User's Guide).
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.